#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>

int main()
{
        int fd1,fd2;
        // 0,1,2
        fd1=open("test",O_CREAT | O_WRONLY,0777);//fd1=3 fd1->test
        if(fd1<0)
        {
                printf("open\n");
        }
        //0,1,2,3
        //close(2);
        //0,2,3         
        fd2=dup2(fd1,1);//fd2=1 fd2->test
        printf("fd1=%d\n",fd1);
        printf("fd2=%d\n",fd2);

        return 0;
}

